class Solution(object):
    def minSubArrayLen(self, target, nums):
        """
        :type target: int
        :type nums: List[int]
        :rtype: int
        """
        left_index = 0
        right_index = 0
        min_value = len(nums) + 1
        sum = nums[0]
        while True:
            if sum >= target:
                min_value = min(min_value, right_index - left_index + 1)
                sum -= nums[left_index]
                left_index += 1
            else:
                right_index += 1
                if right_index >= len(nums):
                    break
                sum += nums[right_index]
        if min_value > len(nums):
            return 0
        else:
            return min_value


data = Solution()
target = 11
nums = [1,1,1,1,1,1,1,1]
print(data.minSubArrayLen(target, nums))
